package ae.pcfc.etks.online.web.controller;

/* $Id: ReportController 
 * Copyright (C) 2011, Trakhees
 *  
 *  History
 *
 * Date  			Author 					Remarks
 * -------------------------------------------------------------
 * April 13, 2011 	Mohtisham 	        Created
 *
 */

import java.util.Locale;

import javax.annotation.Resource;

import org.dozer.DozerBeanMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.validation.Validator;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

/**
 * abstract Controller that all {@link BaseController}-related requests,
 * 
 * @author Mohtisham
 */

public abstract class BaseController {

	private static Logger log;

	private Validator validator;

	private ResourceBundleMessageSource messageSource;

	private DozerBeanMapper mapper;

	@Resource(name = "validator")
	public void setValidator(Validator validator) {
		this.validator = validator;
	}

	@Resource(name = "messageSource")
	public void setMessageSource(ResourceBundleMessageSource messageSource) {
		this.messageSource = messageSource;
	}

	@Resource(name = "mapper")
	protected void setMapper(DozerBeanMapper mapper) {
		this.mapper = mapper;
	}

	@InitBinder
	public void initBinder(WebDataBinder binder, Locale locale) {
		binder.setValidator(validator);
	}

	protected Validator getValidator() {
		return validator;
	}

	protected ResourceBundleMessageSource getMessageSource() {
		return messageSource;
	}

	protected DozerBeanMapper getMapper() {
		return mapper;
	}

	public static Logger getLog(String name) {
		 
		return LoggerFactory.getLogger(name);
	}
}
